<?php

	if (!empty($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))
		die (__('Please do not load this page directly. Thanks!', 'locality'));

	if ( post_password_required() ) 
	{
		?>
		<p class="nocomments"><?php _e('This post is password protected. Enter the password to view comments.', 'locality') ?></p>
		<?php
		return;
	}


if ( have_comments() ) : 

	?>	
	<h2 class="title"><?php comments_number(__('No Comments','locality'), __('One Comment','locality'), __('% Comments','locality') );?></h2>
	<ol class="comment-wrapper">
		<?php wp_list_comments('type=comment&callback=mytheme_comment'); ?>
	</ol>	
	<?php
	 
else : // this is displayed if there are no comments so far 
	
	if ( comments_open() ) : 
		?>
		<!-- If comments are open, but there are no comments. -->
		<?php 
	else : // comments are closed 
		?>
		<!-- If comments are closed. -->
		<?php /*?><p class="nocomments"><?php _e('Comments are closed.', 'locality') ?></p><?php */?>
		<?php 
	endif; 
		
endif; 

if ( comments_open() ) : 

	?>
	<div id="respond">
	
			<div class="cancel-comment-reply">
				<small><?php cancel_comment_reply_link(); ?></small>
			</div>
			
			<div class="title-content-col">
				<h3 class="title"><?php _e('Leave a Reply', 'locality') ?></h3>
			</div>
												
			<?php if ( get_option('comment_registration') && !is_user_logged_in() ) : ?>
				<p><?php _e('You must be', 'locality') ?><a href="<?php echo wp_login_url( get_permalink() ); ?>"><?php _e('logged in', 'locality') ?></a><?php _e('to post a comment.', 'locality') ?></p>
			<?php else : ?>
			
			<div class="form-container">			
				<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">									
					<?php if ( is_user_logged_in() ) : ?>
						<p><?php _e('Logged in as','locality'); ?> <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><?php echo $user_identity; ?></a>. <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="<?php _e('Log out of this account', 'locality') ?>"><?php _e('Log out &raquo;', 'locality') ?></a></p>
					<?php else : ?>
						<p><label for="author"><?php _e('Name*','locality'); ?></label><input type="text" class="textfield field-margin" name="author" id="author" value="<?php echo esc_attr($comment_author); ?>" size="40" tabindex="1" <?php if ($req) echo "aria-required='true'"; ?> /></p>
						<p><label for="email"><?php _e('Mail*','locality'); ?></label><input type="text" class="textfield" name="email" id="email" value="<?php echo esc_attr($comment_author_email); ?>" size="40" tabindex="2" <?php if ($req) echo "aria-required='true'"; ?> /></p>
						<p><label for="url"><?php _e('Website','locality'); ?></label><input type="text" class="textfield full-wide" name="url" id="url" value="<?php echo esc_attr($comment_author_url); ?>" size="40" tabindex="3" /></p>
					<?php endif; ?>							
					<!--<p><small><strong>XHTML:</strong> You can use these tags: <code><?php echo allowed_tags(); ?></code></small></p>-->					
					<p>
						<label for="comment"><?php _e('Comment','locality'); ?></label>
						<textarea name="comment" id="comment" cols="60" rows="10" tabindex="4"></textarea>
					</p>							
					<p>
						<input name="submit"  class="submit-btn" type="submit" id="submit" tabindex="5" value="Submit" />
						<?php comment_id_fields(); ?>
					</p>								
					<?php do_action('comment_form', $post->ID); ?>					
				</form>
			</div>						
			<?php endif; // If registration required and not logged in ?>	
    </div>
<?php endif; // if you delete this the sky will fall on your head ?>